package com.qwz.learn;
/**
* @Description:  组合模式客户端
* @Package: com.qwz.learn.Client
* @Author: Qiuwuzhi
* @CreateDate: 2019/12/20  下午 9:42
* @Version V1.0
*/
public class Client {

    public static void main(String[] args){
        Component root = new Composite();
        Component c1 = new Composite();
        Component c2 = new Composite();

        Component leaf1 = new Leaf();
        Component leaf2 = new Leaf();
        Component leaf3 = new Leaf();

        root.addChild(c1);
        root.addChild(c2);
        root.addChild(leaf1);
        c1.addChild(leaf2);
        c2.addChild(leaf3);

        Component child = root.getChild(1);
        System.out.println(child);
    }




}
